package com.cy.pj.sys.service.impl;

import com.cy.pj.sys.dao.SysNoticeDao;
import com.cy.pj.sys.pojo.SysNotice;
import com.cy.pj.sys.service.SysNoticeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 公告业务的具体实现
 * 1 核心业务(调用数据层)
 * 2 拓展业务(日志记录 权限控制 事务控制 缓存...)
 */
@Slf4j
@Service
public class SysNoticeServiceImpl implements SysNoticeService {
    /**创建日志门面API对象*/
//   private static final Logger log=
//            LoggerFactory.getLogger(SysNoticeServiceImpl.class);

    //@Autowired
    private SysNoticeDao sysNoticeDao;
    //通过构造方法直接进行DI操作
    public SysNoticeServiceImpl(SysNoticeDao sysNoticeDao){
        this.sysNoticeDao=sysNoticeDao;
    }

    @Override
    public int saveNotice(SysNotice notice) {
        int rows = sysNoticeDao.insertNotice(notice);
        return rows;
    }

    @Override
    public List<SysNotice> findNotices(SysNotice notice) {
        log.debug("start:{}",System.currentTimeMillis());
        List<SysNotice> list = sysNoticeDao.selectNotice(notice);
        log.debug("end:{}",System.currentTimeMillis());
        return list;
    }

    @Override
    public int deleteById(Long... ids) {
        int rows=sysNoticeDao.deleteById(ids);
        return rows;
    }

    @Override
    public SysNotice findById(Long id) {
        SysNotice notice = sysNoticeDao.selectById(id);
        return notice;
    }

    @Override
    public int updateNotice(SysNotice notice) {
        int rows= sysNoticeDao.updateNotice(notice);
        return rows;
    }
}
